package com.yt.phone.service;



import org.apache.dubbo.config.annotation.DubboService;

import org.springframework.beans.BeanUtils;

import javax.annotation.Resource;

import com.yt.phone.common.config.YmlConfig;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import com.yt.phone.mapper.PhoneBillMapper;

import com.yt.phone.models.service.IPhoneBillService;

import com.yt.phone.models.bo.PhoneBillSaveBO;

import com.yt.phone.models.dto.PhoneBillDTO;



/**

 * 用户账单信息联表控制器

 *

 * @author lizicong

 * @Date 2025-11-05 23:17:03

 */

@DubboService

public class PhoneBillServiceImpl extends ServiceImpl<PhoneBillMapper, PhoneBillDTO> implements IPhoneBillService{



    @Resource

    private YmlConfig ymlConfig;



    @Override

    public boolean add(PhoneBillSaveBO saveBO) {

        PhoneBillDTO dto = new PhoneBillDTO();

        BeanUtils.copyProperties(saveBO,dto);

        Long id = ymlConfig.getPkId();

        dto.setId(id);

        return this.insert(dto);

    }

    

    /**

     * 根据用户ID和账单ID查询用户账单关联信息

     * @param userId 用户ID

     * @param billId 账单ID

     * @return 用户账单关联信息

     */

    public PhoneBillDTO getByUserAndBillId(Long userId, Long billId) {

        com.baomidou.mybatisplus.mapper.EntityWrapper<PhoneBillDTO> wrapper = new com.baomidou.mybatisplus.mapper.EntityWrapper<>();

        wrapper.eq("user_id", userId).eq("bill_id", billId);

        return this.selectOne(wrapper);

    }

}
